//class MyThread8 extends Thread{
//    @Override
//    public void run(){
//        while(isQuit){
//            System.out.println("thread\n");
//            try {
//                Thread.sleep(1000);
//            } catch (InterruptedException e) {
//                throw new RuntimeException(e);
//            }
//        }
//    }
//}
public class ThreadDemo8 {
    private static  boolean isQuit = false;
    public static void main(String[] args) throws InterruptedException {

        //Thread t = new (MyThread8);
        Thread t = new Thread(()->{
            while(!isQuit){
                System.out.println("thread\n");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();

        Thread.sleep(3000);
        System.out.println("让t线程结束\n");
        isQuit = true;

    }
}
